<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button onclick="cc()" style="width: 200px;height: 50px;background-color: aqua;"></button>
    <script>
        function cc() {
            //创建ajax对象
            var xmlhttp = new XMLHttpRequest();
            //写链接
            xmlhttp.open("GET", "http://127.0.0.1/hui/php/xx.php");
            //请求头
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
            //POST的传参
            xmlhttp.send();
            //成功后刷新页面
            xmlhttp.addEventListener("readystatechange", function () {
            //   alert("cc");
            });
        }
    </script>
</body>

</html>